package com.cq.ssm.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.cq.ssm.mapper.StuffMapper;
import com.cq.ssm.mapper.StuffMapperCustom;
import com.cq.ssm.mapper.StuffdepartmentMapper;
import com.cq.ssm.po.StuffCustom;
import com.cq.ssm.po.StuffQueryVo;
import com.cq.ssm.service.StuffService;

@Component("stuffService")
public class StuffServiceImpl implements StuffService {

	@Autowired
	private StuffMapper stuffMapper;
	@Autowired
	private StuffMapperCustom stuffMapperCustom;
	@Autowired
	private StuffdepartmentMapper stuffdepartmentMapper;
	public List<StuffCustom> queryStuffs(StuffQueryVo sqv)  throws Exception{
		return stuffMapperCustom.findStuffList(sqv);
	}
	public boolean insertStuff(StuffCustom stuffCustom) throws Exception {
		int i = stuffMapper.insertSelective(stuffCustom);
		return i==1?true:false;
	}
	public boolean updateStuffById(String id,StuffCustom record) throws Exception {
		record.setIdStuff(id);
		int i = stuffMapper.updateByPrimaryKeySelective(record);
		return i==1?true:false;
	}
//	public StuffCustom findStuffByStuffId(Integer id) throws Exception {
//		return stuffMapperCustom.findStuffByStuffId(id);
//	}
//	public List<StuffCustom> findStuffByStuffDepartmentId(Integer id)
//			throws Exception {
//		return stuffMapperCustom.findStuffByStuffDepartmentId(id);
//	}
	public boolean deleteByStuffId(String id) throws Exception {
		int i = stuffMapper.deleteByPrimaryKey(id);
		return i==1?true:false;
	}
	
	public boolean updateDepartmentId(String id) throws Exception{
		int i = stuffMapperCustom.updateStuffDepartmentId(id);
		return i==1?true:false;
	}
}
